package com.rjkj.medicalwaste.adapter

import android.util.Log
import android.view.View

interface ItemClick<T> {
    fun onClicked(view: View, value: T)
}
interface ItemDataClick<T> {
    fun onClicked( value: T)
}
interface InvalidClick {
    fun onInvalidClick(l:Long)
}
abstract class OnMultiClickListener : View.OnClickListener {
    abstract fun onMultiClick(v: View?)
    abstract fun onInvalidClick(long:Long)
    override fun onClick(v: View) {
        val curClickTime = System.currentTimeMillis()
        val l = curClickTime - lastClickTime
        if ( l>= MIN_CLICK_DELAY_TIME) {
            lastClickTime = curClickTime
            onMultiClick(v)
        }else{
            onInvalidClick(MIN_CLICK_DELAY_TIME-l)
        }
    }

    companion object {
        // 两次点击按钮之间的点击间隔
        private const val MIN_CLICK_DELAY_TIME = 3000
        private var lastClickTime: Long = 0
    }
}
abstract class OnMultiClickDataListener<T>(val value: T) : View.OnClickListener {
    abstract fun onMultiClick(data:T,v: View?)
    abstract fun onInvalidClick(long:Long)
    override fun onClick(v: View?) {
        Log.e("View", "onClick: sssssssssssss", )
        val curClickTime = System.currentTimeMillis()
        val l = curClickTime - lastClickTime
        if ( l>= MIN_CLICK_DELAY_TIME) {
            lastClickTime = curClickTime
            onMultiClick(value,v)
        }else{
            onInvalidClick(MIN_CLICK_DELAY_TIME-l)
        }
    }

    companion object {
        // 两次点击按钮之间的点击间隔
        private const val MIN_CLICK_DELAY_TIME = 3000
        private var lastClickTime: Long = 0
    }
}